<?php


function bfsql_fir($array,$strip=true) {
	$array = bfesc($array,$strip,true);
	$str = '';
	foreach ($array as $key => $val) {
		$str .= ($str ? ', ' : ' ').$key.'='.$val;
	}
	return $str;
}


function bfesc($var,$strip = true,$is_array=false) {
	if (is_array($var)) {
		if (!$is_array) return " '' ";
		foreach ($var as $key => $value) {
			$var[$key] = trim(bfesc($value,$strip));
		}
		return $var;
	} elseif (is_numeric($var)) {
		return " '".$var."' ";
	} else {
		return " '".addslashes($strip ? stripslashes($var) : $var)."' ";
	}
}
